/**
   @file generator.h
   @brief Function prototypes to implement the underlying workload generator functionality.
 */

#ifndef WG_GENERATOR_HEADER
#define WG_GENERATOR_HEADER

#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include "cJSON.h"
#include "scheduler.h"
#include "resource_model.h"

/** The number of resource threads to run. Used by the rendezvous system. */
#define CNT_RESOURCES 5

/** Set up all the necessary data structures required by the workload generator. */
void setup_generator();

/** Translate a JSON file into a struct the program can easily access. */
cJSON * parse_config(void);

/** Generate a workload for a specific resource. */
int workload_generator(cJSON *, char *, resource_model * (*)(cJSON *), pthread_t *);

/** The controller that schedules a workload. Runs in its own thread. */
void * thr_resource(void *);

/** Make a struct timespec that represents the point in time some milliseconds from now. */
struct timespec * ms_from_now(double);

/** Find the difference between two points in time in nanoseconds. */
struct timespec *timeval_diff(struct timespec *, struct timespec *);

#endif
